#include<iostream>
#include<vector>
#include<map>
using namespace std;

// 错因
class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        map<int, int> mp;
        int n = numbers.size();
        int idx = 0;

        for (int i = 0; i < n; i++) {
            idx = mp[target - numbers[i]];
            if (idx != 0) {
                return {idx, i + 1};
            }
            
            // 这里应该是mp[numbers[i]] = i + 1;
            mp[numbers[i]] = idx + 1;
        }

        return {};
    }
};

int main(){
    Solution s;

    vector<int> numbers = {5, 25, 75};
    vector<int> res = s.twoSum(numbers, 100);

    if (res.size() == 0) cout << "empty!" << endl;
    else{
        for (int i = 0; i < res.size(); i ++) {
            cout << res[i] << " ";
        }
        cout << endl;
    }
    
    return 0;
}